package com.创建型模型.C构建者模式.黑马demo;

/**
 * @author zhangjiawen
 * @Date: 2022/6/13 9:24
 */
public class Phone {

    private String cpu;
    private String memory;
    private String dist;
    private String screen;

    private Phone(Builder builder){
        this.cpu=builder.cpu;
        this.memory=builder.memory;
        this.dist=builder.dist;
        this.screen=builder.screen;
    }

    public static final class Builder{

        private String cpu;
        private String memory;
        private String dist;
        private String screen;
        public Builder() {}
        public Builder cpu(String cpu) {
            this.cpu = cpu;
            return this;
        }
        public Builder memory(String memory) {
            this.memory = memory;
            return this;
        }
        public Builder dist(String dist) {
            this.dist = dist;
            return this;
        }
        public Builder screen(String screen) {
            this.screen = screen;
            return this;
        }

        public Phone build(){
            return new Phone(this);
        }

    }


    @Override
    public String toString() {
        return "Phone{" +
                "cpu='" + cpu + '\'' +
                ", memory='" + memory + '\'' +
                ", dist='" + dist + '\'' +
                ", screen='" + screen + '\'' +
                '}';
    }
}
